/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Controleur.TableModel;

import Modele.Velo;
import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author 20cent
 */
public class VeloTableMobel extends AbstractTableModel{

    public VeloTableMobel(ArrayList<Velo> velos) {
        this.velos = velos;
    }
 
    
    private ArrayList<Velo> velos;
    public static final String[] COLONNES = {"ID" ,
                                            "Numéro de série",
                                            "Date de mise en circulation"};

    public void setVelos(ArrayList<Velo> velos) {
        this.velos = velos;
        fireTableDataChanged();
    }
   
    
    @Override
    public int getRowCount() {
        return velos.size();
    }

    @Override
    public int getColumnCount() {
        return COLONNES.length;
    }

    @Override
    public String getColumnName(int column) {
        return COLONNES[column];
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        Velo velo = velos.get(rowIndex);
        switch (columnIndex){
            case 0 :
                return velo.getMId();
            case 1 :
                return velo.getmSerial();
            case 2 :
                return velo.getMDateEntree();
            default : 
                return null;
        }
    }

    @Override
    public Class<?> getColumnClass(int columnIndex) {
        return getValueAt(0, columnIndex).getClass();
    }

    @Override
    public boolean isCellEditable(int rowIndex, int columnIndex) {
        return false;
    }

 
    
    
    
}
